package com.futao.csdn;

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.RequestEntity;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;

import java.net.URI;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

/**
 * @author ft
 * @date 2021/5/26
 */
public class Review {
    public static void main(String[] args) throws Exception {
        RestTemplate restTemplate = new RestTemplate();
        String url = UriComponentsBuilder.fromHttpUrl("https://blog.csdn.net/phoenix/web/v1/comment/submit")
                .build()
                .toString();

        Map<String, String> map = new HashMap<>();
        map.put("content", "几句话完事的东西，浪费那么多csdn内存干什么??制造网络垃圾？");
        map.put("articleId", "107654592");
        map.put("commentId", "");
        HttpHeaders httpHeaders = new HttpHeaders();
        httpHeaders.add("content-type","application/x-www-form-urlencoded; charset=UTF-8");
        httpHeaders.add("cookie","uuid_tt_dd=10_18672353300-1615343463429-187371; ssxmod_itna=eqGOD5GKAK4UgjDzpKRx0I24mT4YqKwxhn50QHDl6oxA5D8D6DQeGTbRo5pses=tBiawWqBBwPxzjibiP5QCWZjmPDHxY=DU1SupXD4RKGwD0eG+DD4DWDmnFDnxAQDj2KGWDbr=GfDGeDeEKODY5DhxDC0mPDwx0Cfh2oeAFGOaBC=Kyoxt0DfxG1N40Hdi8poFSEeAv3mx0k040Oc=v80cYDU7b4flr4bnuxbCRXqB0NCCDNeMD07n0KpD4NN0C4xkha4qDWslpa4D; ssxmod_itna2=eqGOD5GKAK4UgjDzpKRx0I24mT4YqKwxhn50QD6pUlpD0v5503ddvcUXD6l=NQd2xz7I6qAwPX/iMYIPuC2OgQ4r5icSiA5VZgcDsF5BDQU27DvByXRqDSwQ7L2THeAlB6E+N=UBpgqGXQ9NEcTaM6Tr1oytLhKND=IqED07el4DLxG7eYD=; UserName=futao__; UserInfo=15650d1e23e241588917292b0ca2c2fe; UserToken=15650d1e23e241588917292b0ca2c2fe; UserNick=Niubist_; AU=0EC; UN=futao__; BT=1615942629313; p_uid=U010000; Hm_up_6bcd52f51e9b3dce32bec4a3997715ac=%7B%22islogin%22%3A%7B%22value%22%3A%221%22%2C%22scope%22%3A1%7D%2C%22isonline%22%3A%7B%22value%22%3A%221%22%2C%22scope%22%3A1%7D%2C%22isvip%22%3A%7B%22value%22%3A%220%22%2C%22scope%22%3A1%7D%2C%22uid_%22%3A%7B%22value%22%3A%22futao__%22%2C%22scope%22%3A1%7D%7D; Hm_ct_6bcd52f51e9b3dce32bec4a3997715ac=6525*1*10_18672353300-1615343463429-187371!5744*1*futao__; Hm_lvt_e5ef47b9f471504959267fd614d579cd=1616026966; __gads=ID=7d51661633395fac-22790f8183c700c3:T=1619149473:RT=1619149473:S=ALNI_Ma_W3_l7miDBprU2TN5u1VK9jupWw; UM_distinctid=179404c1a351c7-0d02c2b24e9eab-d7e1739-1fa400-179404c1a36e1e; pluginUUID=10_28101498179-1620293040478-004721; pluginId=kfkdboecolemdjodhmhmcibjocfopejo; dc_session_id=10_1621997936503.197321; c_first_ref=default; c_first_page=https%3A//www.csdn.net/; c_segment=11; Hm_lvt_6bcd52f51e9b3dce32bec4a3997715ac=1621913769,1621991693,1621994004,1621997938; announcement-new=%7B%22isLogin%22%3Atrue%2C%22announcementUrl%22%3A%22https%3A%2F%2Fblog.csdn.net%2Fblogdevteam%2Farticle%2Fdetails%2F112280974%3Futm_source%3Dgonggao_0107%22%2C%22announcementCount%22%3A0%2C%22announcementExpire%22%3A3600000%7D; dc_sid=6d2e47ed7a42f7d5137be10ff2998536; c_ref=https%3A//blog.csdn.net/qq_25497867; aliyun_webUmidToken=T2gAGRGfB84AoMinIowpJKFf25Iwlu01MMk0zjtLKKMeGw0PPb351dHVm4_giVrQXh0=; c_pref=https%3A//blog.csdn.net/qq_25497867; c_page_id=default; dc_tos=qtp1pv; log_Id_pv=83; Hm_lpvt_6bcd52f51e9b3dce32bec4a3997715ac=1621998068; log_Id_view=167; log_Id_click=17");

        new RequestEntity<>(map, httpHeaders, HttpMethod.POST, URI.create(url));
        System.out.println(restTemplate.postForEntity(url, map, String.class).getBody());
    }
}
